<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />


        <script type="text/css">
            .roleclass { color:#fff;}
            .objectclass { color:#fff;}
        </script>

        <script type="text/javascript">
            //var i = 0;
            function addp()
            {
                var i = $(".autocomplete").length;
                //alert("i = "+i);
                if (i < 4)
                {
                    i++;
                }
                else
                {
                    alert('up to four!');
                    return;
                }
                //alert("i = "+i);
                str = '<p id="p' + i + '">'
                    +'<input type="text" size="39"  placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" '
                    +' name="row[item][]" id="itemid' + i + '" class="autocomplete" table="type_object" autocomplete="off" >'
                    +'<input type="text" size="8" placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" '
                    +' name="row[amount][]" id="num' + i + '" >'
//                    +'<?//=translate('MAIL_EQUIPLEVEL')  ?>//'
//                    +'<select name="row[equiplevel][]" id="equiplevel'+i+'" >'
//                    +'<?php //for ($i=0; $i<=10;++$i) { ?>//'
//                    +'<option value="<?//=$i ?>//"><?//=$i ?>//</option>'
//                    +'<?php //}?>//'
//                    +'</select>'
                    +'</p>';
                //alert(" str = "+str);
                $("#add").append(str);
                autocomplete();

                $("#num"+i).formValidator({empty: false, onshow: '<?= translate('MAIL_TIME_LIMIT_MIN_MAX') ?>'})
                    .inputValidator({type: 'number', min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});

            }
            function removep()
            {
                var i = $(".autocomplete").length;
                //alert("i = "+i);
                if (i > 0)
                {
                    $("#p" + i).remove();
                }

            }
        </script>
    </head>
    <body>

        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <form action="" method="POST" id="rowForm" onsubmit="return comf()">
<!--            <input type="hidden" id="rechargeid" name="row[rechargeid]" value=4>-->
<!--            <input type="hidden" id="rechargevalue" name="row[rechargevalue]" value=600>-->
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
              	<tr align="left">
                    <th></th>
                    <th></th>
                </tr>


 <!--   下拉列表选区改为多选框，改为可以选择多个区            <tr align="left"><td width="45"><?= translate('SELECT_AREA') ?>:</td><td><?= $arealist ?></td></tr>
-->
                <tr align="left">
                    <td align="left"><?= translate('SELECT_AREA') ?></td>
                    <td>
                        <?php foreach ($arealist as $key => $value) { ?>
                            <input type="radio" name="row[area][]" value="<?=$key ?>"><?=$value ?>
                        <?php }?>
                    </td>
                </tr>

                <tr align="left" hidden>
                    <td><?= translate('SEND_MAIL_TYPE') ?></td>
                    <td colspan="5">
                        <input type="radio" name="row[enable]" value="0" id="send2all" size="0" /> <?= translate('SEND_2_ALL') ?>
                        <input type="radio" name="row[enable]" value="1" id="sendbyfightvalue" size="0" /> <?= translate('SEND_BY_FIGHT_VALUE') ?>
                        <input type="radio" name="row[enable]" value="2" id="sendbylevel" size="0" /> <?= translate('SEND_BY_LEVEL') ?>
                        <input type="radio" name="row[enable]" value="3" id="snedbyroleid" size="0" /> <?= translate('SEND_BY_ROLE_ID') ?>
                    </td>
                </tr>


                <tr align="left" hidden><td width="45"><?= translate('ROLE_FIGHT_VALUE_L') ?>:</td><td colspan="5"><input type="text" name="row[role_fight_value_l]" id="rolefightvaluel" size="25" /></td></tr>
                <tr align="left" hidden><td width="45"><?= translate('ROLE_FIGHT_VALUE_H') ?>:</td><td colspan="5"><input type="text" name="row[role_fight_value_h]" id="rolefightvalueh" size="25" /></td></tr>
                <tr align="left" hidden><td width="45"><?= translate('ROLE_LEVEL') ?>:</td><td colspan="7"><input type="text" name="row[role_level]" id="rolelevel" size="25" /></td></tr>

                <tr align="left"><td width="45"><?= translate('ROLE_ID') ?>:</td><td colspan="5"><textarea name="row[role_id]" id="roleid" cols="100" rows="11" ></textarea></td></tr>
                <tr align="left" hidden><td width="45"><?= translate('RECHARGE_TITLE')?>:</td><td colspan="5"><input type="number" name="row[title]" id="title" size="25" value="6"/></td></tr>
                <tr align="left" hidden><td width="45"><?= translate('SEAL_MSG') ?>:</td><td colspan="5"><textarea name="row[msg]" id="msg" cols="100" rows="11"></textarea></td></tr>
<!--                fjkldsajfldajf-->
                <tr align="left" hidden >
                    <td align="left"><?= translate('SELECT_RECHARGE') ?></td>
                    <td>
                <input type="radio" name="row[rechargetype][]" value=4 checked>6元
                <input type="radio" name="row[rechargetype][]" value=5>30元
                <input type="radio" name="row[rechargetype][]" value=6>68元
                <input type="radio" name="row[rechargetype][]" value=7>128元
                <input type="radio" name="row[rechargetype][]" value=8>328元
                <input type="radio" name="row[rechargetype][]" value=9>648元
                    </td>
                </tr>
<!--                fdsfdasfdasfads-->
                <tr align="left" ><td width="45"><?= translate('RECHARGE_ID')?>:</td><td colspan="5"><input type="number" name="row[rechargeid]" id="title" size="25" value="4"/></td></tr>
                <tr align="left" ><td width="45"><?= translate('RECHARGE_VALUE')?>:</td><td colspan="5"><input type="number" name="row[rechargevalue]" id="title" size="25" value="600"/></td></tr>
                <tr align="left" hidden><td width="45"><?= translate('OBJECT_GMID') ?>:</td><td id="add" size="25">
                        <p id="p">
                            <input type="button" onclick="addp()" value="<?= translate('ADD_ONE') ?>" />
                            <input type="button" onclick="removep()" value="<?= translate('REMOVE_ONE') ?>" />
                        </p>
                    </td></tr>
                <tr><td></td><td><input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset" hidden/></td></tr>
            </table>
        </form>
        <script type="text/javascript">
            SG.init("core.form", function() {
                $.formValidator.initConfig({formid: "#rowForm", submitonce: false});
                $("#area_host").formValidator({empty: false, onshow: '<?= translate('PLASE_SELECT') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#title").formValidator({empty: false, onshow: '<?= translate('PLEASE_INPUT_RECHARGE_NUM') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                //$("#rolelevel").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                //$("#rolefightvaluel").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                //$("#rolefightvalueh").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});
                //$("#roleid").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'}); 
                $("#gmid").formValidator({empty: false, onshow: '<?= translate('C_ONLY_NUM') ?>'}).regexValidator({regexp: 'num', datatype: 'enum', onerror: '<?= translate('C_ONLY_NUM') ?>'});

                // $("#rolefightvaluel").attr("disabled",true);
                // $("#rolefightvalueh").attr("disabled",true);
                // $("#rolelevel").attr("disabled",true);
                // $("#roleid").attr("disabled",true);
                // $("#title").attr("disabled",true);
                // $("#msg").attr("disabled",true);
            });
            $(function(){
                $('input:radio[name="row[rechargetype][]"]').click(function(){
                    var checkvalue = $("input[name='row[rechargetype][]']:checked").val();
                    var checkvalueInt=parseInt(checkvalue)
                    switch (checkvalueInt){
                        case 3:
                            $("#rechargevalue").val(100);
                            break;
                        case 4:
                            $("#rechargevalue").val(600);
                            break;
                        case 5:
                            $("#rechargevalue").val(3000);
                            break;
                        case 6:
                            $("#rechargevalue").val(6800);
                            break;
                        case 7:
                            $("#rechargevalue").val(12800);
                            break;
                        case 8:
                            $("#rechargevalue").val(32800);
                            break;
                        case 9:
                            $("#rechargevalue").val(64800);
                            break;
                    }
                    $("#rechargeid").val(checkvalueInt);
                });

                // $(":radio").click(function(){
                //     $("#title").attr("disabled",false);
                //     $("#msg").attr("disabled",false);
                //
                //     //将相应的输入框改变状态
                //     //$('input').attr("disabled",true)
                //     var a = $("input[name='row[enable]']:checked").val();
                //     if (a == 0 || a == 4){ //全部输入框disable
                //         //alert("send to all");
                //         $("#rolefightvaluel").attr("disabled",true);
                //         $("#rolefightvalueh").attr("disabled",true);
                //         $("#rolelevel").attr("disabled",true);
                //         $("#roleid").attr("disabled",true);
                //     }else  if (a == 1){
                //         //alert("send by role level");
                //         $("#rolefightvaluel").attr("disabled",false);
                //         $("#rolefightvalueh").attr("disabled",false);
                //         $("#rolelevel").attr("disabled",true);
                //         $("#roleid").attr("disabled",true);
                //     }else if (a==2){
                //         //alert("send by role fight value");
                //         $("#rolefightvaluel").attr("disabled",true);
                //         $("#rolefightvalueh").attr("disabled",true);
                //         $("#rolelevel").attr("disabled",false);
                //         $("#roleid").attr("disabled",true);
                //     }else if (a==3){
                //         //alert("send by role level");
                //         $("#rolefightvaluel").attr("disabled",true);
                //         $("#rolefightvalueh").attr("disabled",true);
                //         $("#rolelevel").attr("disabled",true);
                //         $("#roleid").attr("disabled",false);
                //     }else{
                //         //alert("no select ");
                //         $("#rolefightvaluel").attr("disabled",false);
                //         $("#rolefightvalueh").attr("disabled",false);
                //         $("#rolelevel").attr("disabled",false);
                //         $("#roleid").attr("disabled",false);
                //     }
                //
                //
                // });
                $('input:radio[name="row[area][]"]:first').attr('checked', 'checked');
            });
            function comf(){
                // var str="";
                // $("input[type='checkbox']:checked").each(function(){
                //     str +=$(this).attr("val")+"，";
                // })
                // if(!str){
                //     alert("亲，您没有选择吧");return false;
                // }
                return confirm("您开始提交模拟充值吗？");
            }
        </script>
    </body>
</html>
